<?php /* Smarty version Smarty-3.1.13, created on 2014-10-29 21:42:33
         compiled from "D:\PHPWeb\cms\templates\admin\subject\subjectitems.tpl" */ ?>
<?php /*%%SmartyHeaderCode:138525450eec9b6cc04-15098940%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    'bb4dd0bc8dc66185d0e1c4c6450fe7e57385b74f' => 
    array (
      0 => 'D:\\PHPWeb\\cms\\templates\\admin\\subject\\subjectitems.tpl',
      1 => 1414589332,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '138525450eec9b6cc04-15098940',
  'function' => 
  array (
  ),
  'has_nocache_code' => false,
  'version' => 'Smarty-3.1.13',
  'unifunc' => 'content_5450eec9bc1e08_02071529',
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_5450eec9bc1e08_02071529')) {function content_5450eec9bc1e08_02071529($_smarty_tpl) {?> 
<style>
#subItemWin {
	margin: -500px 0 0 -280px;
	/* PLAY THE WITH THE VALUES TO SEE GET THE DESIRED EFFECT */
}
</style>
<script type="text/javascript">


function showSubjectItems(){
	var select = getSelectSubject();
	if( select == null){
		$.messager.alert('信息',"未选择指定的专题");
		return;
	}
	reloadGrids();
	
}

function openAddSubItem(){
	var select = getSelectSubject();
	if( select == null){
		$.messager.alert('信息',"未选择指定的专题");
		return;
	}
	 $('#subItemWin').modal('show');
	 $("#subitemform").form('clear');
	 $('#subjectid').attr("value",select.id);
}

function subjectItemAddOrModify(){
	  if(!$('#subitemform').form('validate')){
	        return;
	     }
  		$.post(
			'<?php echo @constant('WEBSITE_URL');?>
admin/subject/saveOrModifySubItem',
			$('#subitemform').serialize(),
			function(data){ 
				$('#subItemWin').modal('hide');
				reloadGrids();
			},
			"json"
  		);
}
function reloadGrids(){
	var select  = getSelectSubject();
	if(select == null){
		$.messager.alert('信息',"未选择指定的产品");
		return null;
	}
	$('#subItemsgrid').datagrid({
		 url:'<?php echo @constant('WEBSITE_URL');?>
admin/subject/pageSubjectItems',
		 queryParams:{id: select.id}
	});
	$('#subItemsgrid').datagrid('reload'); 
}
function modifySubItem(){
	var select  = $("#subItemsgrid").datagrid('getSelected');
	if(select == null){
		$.messager.alert('信息',"未选择指定的产品");
		return null;
	}
	$("#subitemform").form('clear');
	 $('#subItemWin').modal('show');
	$("#subitemform").form('load',select);
}
function delSubItem(){
	var select  = $("#subItemsgrid").datagrid('getSelected');
	if(select == null){
		$.messager.alert('信息',"未选择指定的产品");
		return null;
	}

	$.ajax({  
        type: "POST",  
        dataType: "json",  
        url: '<?php echo @constant('WEBSITE_URL');?>
admin/subject/deleteSubItem',
        data: { id: select.id },  
        success: function (data) {  
        	reloadGrids();
        },  
        error: function () {  
        }  
    });  
}

		 
</script>
<div class="form-actions">
	<h3>专题下商品管理..请在上面专题列表中选择一项.然后进行下面的操作 </h3>
  <button type="button" class="btn btn-primary" onclick="showSubjectItems()">查看专题商品</button>
  <button type="button" class="btn btn-primary" onclick="openAddSubItem()">添加新商品</button>
  <button type="button" class="btn btn-info" onclick="modifySubItem()">修改产品</button>
  <button type="button" class="btn btn-danger"  onclick="delSubItem()">删除产品</button>
</div>

			<table id="subItemsgrid"
				data-options="fitColumns:true,singleSelect:true"
				class="easyui-datagrid" style="width: auto; height: 350px"
				toolbar="#subitemtoolbar" iconCls="icons-save" pagination="true"
				rownumbers="true">
				<thead>
					<tr>
						<th data-options="field:'subjectid',hidden:true"></th>  
						<th data-options="field:'id',width:100,checkbox:true"></th>
						<th data-options="field:'name',width:100">产品名称</th>
						<th data-options="field:'img',width:100">产品图片</th>
						<th data-options="field:'url',width:100">地址</th>
						<th data-options="field:'index',width:100">序列</th>
						<th data-options="field:'oldprice',width:100">原始价格</th>
						<th data-options="field:'newprice',width:100">新价格</th>
						<th data-options="field:'unit',width:100">单位</th>
						<th data-options="field:'saveprice',width:100">节约价格</th>
						<th data-options="field:'returnpoints',width:100">返回积分</th>
						<th data-options="field:'create_time',width:100">创建时间</th>
						<th data-options="field:'desc',width:100">描述</th>
					</tr>
				</thead>
			</table>
			
			
	<div id="subItemWin" class="modal hide fade">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h5>专题下产品管理</h5>
				</div>
				<div class="modal-body">
					<form id="subitemform" method="post" class="form-horizontal">
						<div class="control-group" hidden="true">
							<input type="text" name="id" hidden="true">
							<input type="text" id="subjectid" name="subjectid" hidden="true">
						</div>
						<div class="control-group">
							<label class="control-label" for="Text input">产品名称:</label>
							<div class="controls">
								<input type="text" class="easyui-validatebox"
									data-options="required:true" id="name" name="name"
									 placeholder="产品名称">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label"  >产品的图片:</label>
							<div class="controls">
								<input type="text" class="easyui-validatebox"
									id="img" name="img"
									placeholder="添加图片地址"></input> 
							</div>
						</div>

						<div class="control-group">
							<label class="control-label"  >序列:</label>
							<div class="controls">
								<input type="text" id="index" name="index"
									placeholder="商品序列,如果是1就第一个显示">
							</div>
						</div>
						
						<div class="control-group">
							<label class="control-label"  >链接地址:</label>
							<div class="controls">
								<input type="text" id="url" name="url"
									placeholder="链接地址:">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label"  >原始价格:</label>
							<div class="controls">
								<input type="text" id="oldprice" name="oldprice"
									placeholder="原始价格:">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label"  >最新价格:</label>
							<div class="controls">
								<input type="text" id="newprice" name="newprice"
									placeholder="最新价格:">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label"  >返利积分:</label>
							<div class="controls">
								<input type="text" id="returnpoints" name="returnpoints"
									placeholder="返回积分数">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label"  >描述:</label>
							<div class="controls">
								<textarea rows="2"  id="desc" name="desc"></textarea>
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer" id="div_view">
					<button type="button" style="width: 100px;" class="btn btn-primary"
						onclick="subjectItemAddOrModify()">提交</button>
				</div>
			</div>
		 <?php }} ?>